﻿using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace SZ.Mech
{
    public class CompProperties_IgnoreStun : CompProperties
    {
       public CompProperties_IgnoreStun()
        {
            this.compClass = typeof(IgnoreStunComp);
        }
    }
    public class IgnoreStunComp : ThingComp
    {
        public override void PostPostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
        {
            base.PostPostApplyDamage(dinfo, totalDamageDealt);
            Pawn_StanceTracker stance = (parent as Pawn).stances;
            if(stance.stunner.Stunned)
            {
                FieldInfo value2 = typeof(StunHandler).GetField("stunTicksLeft", BindingFlags.NonPublic | BindingFlags.Instance);
                value2.SetValue(stance.stunner, 0);
                FieldInfo value3 = typeof(StunHandler).GetField("EMPAdaptedTicksLeft", BindingFlags.NonPublic | BindingFlags.Instance);
                value3.SetValue(stance.stunner, 0);
            }
        }
    }
}
